import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BizStationDataCardVo, BizStationDataCardHistoryVo } from './types';

/**
 * 查询列表
 * @param query
 * @returns {*}
 */

export const listDataCard = (query?: PageQuery): AxiosPromise<BizStationDataCardVo[]> => {
  return request({
    url: '/biz-station/station/dataCard/list',
    method: 'get',
    params: query
  });
};

/**
 * 导出列表
 * @param query
 * @returns {*}
 */

export const exportDataCard = (query?: PageQuery): AxiosPromise<BizStationDataCardVo[]> => {
  return request({
    url: '/biz-station/station/dataCard/export',
    method: 'post',
    params: query
  });
};

/**
 * 查询详细
 * @param id
 */
export const getDataCard = (id: string | number): AxiosPromise<BizStationDataCardVo> => {
  return request({
    url: '/biz-station/station/dataCard/' + id,
    method: 'get'
  });
};

/**
 * 查询详细(通过设备ID)
 * @param id
 */
export const getDataCardByDevice = (deviceId: string | number): AxiosPromise<BizStationDataCardVo> => {
  return request({
    url: '/biz-station/station/dataCard/device/' + deviceId,
    method: 'get'
  });
};


/**
 * 查询数据卡操作历史列表
 * @param id
 */
export const getDataCardHistory = (query?: PageQuery): AxiosPromise<BizStationDataCardHistoryVo[]> => {
  return request({
    url: '/biz-station/station/dataCard/list/history',
    method: 'get',
    params: query
  });
};


/**
 * 新增
 * @param data
 */
export const addDataCard = (data: BizStationDataCardVo) => {
  return request({
    url: '/biz-station/station/dataCard',
    method: 'post',
    data: data
  });
};

/**
 * 修改
 * @param data
 */
export const updateDataCard = (data: BizStationDataCardVo) => {
  return request({
    url: '/biz-station/station/dataCard',
    method: 'put',
    data: data
  });
};

/**
 * 删除
 * @param id
 */
export const delDataCard = (id: string | number | Array<string | number>) => {
  return request({
    url: '/biz-station/station/dataCard/' + id,
    method: 'delete'
  });
};

/**
 * 解除数据卡绑定
 * @param id
 */
export const unBindDataCard = (id: string | number | Array<string | number>) => {
  return request({
    url: '/biz-station/station/dataCard/unBinding/' + id,
    method: 'put'
  });
};

/**
 * 数据卡续期
 * @param data
 */
export const renewalDataCard = (data: BizStationDataCardVo) => {
  return request({
    url: '/biz-station/station/dataCard/renewal',
    method: 'put',
    data: data
  });
};

/**
 * 修改数据卡绑定关系
 * @param data
 */
export const changeBindDataCard = (data: BizStationDataCardVo) => {
  return request({
    url: '/biz-station/station/dataCard/changeBinding',
    method: 'put',
    data: data
  });
};

/**
 * 作废
 * @param id
 */
export const abolishDataCard = (id: string | number | Array<string | number>) => {
  return request({
    url: '/biz-station/station/dataCard/abolish/' + id,
    method: 'put'
  });
};